<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>提请协调</title>
    <%@ include file="/WEB-INF/views/modules/commons/head.jsp" %>
    <%--多选css--%>
    <link rel="stylesheet" href="<s:url value="/assets/web/js/multiSelect/css/fselect.css"></s:url>">
    <!-- header -->
    <%@ include file="/WEB-INF/views/include/header.jsp" %>
    <style>

        /*转成省略号*/
        /*.ui-jqgrid tr.jqgrow td { text-overflow : ellipsis; }*/
        .ui-jqgrid tr.jqgrow td {
            white-space: normal !important;
            height: 35px;
            vertical-align: text-top;
            padding-top: 2px;
        }

        .nav {
            margin-left: 0;
        }

        #gview_gridTable .ui-jqgrid-bdiv {
            max-height: 450px;
        !important;
        }

        .nav > li > a:focus, .nav > li > a:hover {
            text-decoration: none;
            background-color: #33CCFF !important;
        }

        #main-container {
            padding-top: 35px;
            position: relative;
            height: calc(100%);
            margin-left: 17.5%;
            margin-top: 60px;
        }

        .modal-dialog {
            z-index: 9999999;
        }

        @media (min-width: 768px) {
            .modal-content {
                -webkit-box-shadow: 0 5px 15px rgba(0, 0, 0, .5);
                box-shadow: 0 -2px 20px rgba(0, 0, 0, .5) !important;
            }
        }

        td {
            cursor: default;
        }

        .search-row {
            margin-left: 7px !important;
        }
    </style>
</head>
<body class="bgcolor">
<%@ include file="/WEB-INF/views/modules/commons/nav.jsp" %>
<%@ include file="/WEB-INF/views/modules/commons/menu.jsp" %>


<!-- /section:basics/navbar.layout -->
<table></table>
<div class="main-container" id="main-container">


    <!-- /section:basics/sidebar -->
    <div class="main-content">
        <%--搜索查询--%>
        <div class="row search-row">
            <div class="col-xs-2">
                <input type="text" class="form-control" placeholder="请输入要搜索的关键词" id="searchWord"/>
            </div>
            <div class="col-xs-8" style="right: 23px;">
                <button class="btn btn-large btn-primary" id="query">搜索</button>
                <button class="btn btn-large btn-success" style="display:none;" id="create">我要协调</button>
                <button class="btn btn-large btn-default" style="display:none;" id="edits">我要修改</button>
                <button class="btn btn-large btn-primary" style="display:none;" id="edits1">审核批转成攻坚任务</button>
                <button class="btn btn-large btn-danger" style="display:none;" id="revoke">撤销协调</button>
                <button class="btn btn-large btn-success" style="display:none;" id="cancelProblem">一键处理完成</button>

            </div>
        </div>
        <div class="main-content-inner">
            <div class="page-content">
                <!-- /section:settings.box -->
                <%--<div class="row">--%>
                <%--<div class="col-xs-12">--%>
                <%--<div class="pull-left">--%>
                <%--&lt;%&ndash;<button class="btn btn-sm btn-info" id="query">条件搜索</button>&ndash;%&gt;--%>
                <%--<button class="btn btn-sm btn-success" style="display:none;" id="create">我要协调</button>--%>
                <%--<button class="btn btn-sm btn-default" style="display:none;" id="edits">我要修改</button>--%>
                <%--<button class="btn btn-sm btn-primary" style="display:none;" id="edits1">审核批转成攻坚任务</button>--%>
                <%--<button class="btn btn-sm btn-danger" style="display:none;" id="revoke">撤销协调</button>--%>
                <%--<button class="btn btn-sm btn-success" style="display:none;" id="cancelProblem">一键处理完成</button>--%>
                <%--&lt;%&ndash;<shiro:hasPermission name="modules:sys:dept:excel">--%>
                <%--<button class="btn btn-sm btn-pink" id="export">导出</button>--%>
                <%--</shiro:hasPermission>&ndash;%&gt;--%>
                <%--</div>--%>
                <%--</div>--%>
                <%--</div>--%>
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <!-- jqGrid表格 -->
                        <table id="gridTable"></table>
                        <!-- jqGrid工具类 -->
                        <div id="gridPager"></div>
                        <!-- 查询对话框 -->
                        <div style="display: none;">
                            <div class="row" id="queryDialog"></div>
                        </div>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
                <div class="row" style="margin-left: 2px;">
                    * 双击列表可查看详情
                </div>
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->

    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
    </a>


</div><!-- /.main-container -->
</div>
<!-- footer -->
<script src="<s:url value="/assets/web/js/jquery.min.js?v=2.1.4"></s:url>"></script>
<%--公用js--%>
<script src="<s:url value="/assets/web/js/commo.js"></s:url>"></script>
<link rel="stylesheet" href="<s:url value="/assets/web/css/login/bootstrap.min.css?v=3.3.6"></s:url>">
<script src="<s:url value="/assets/web/js/jqpaginator.min.js"></s:url>"></script>
<script src="<s:url value="/assets/web/js/baseAPI.js"></s:url>"></script>
<%--多选js--%>
<script src="<s:url value="/assets/web/js/multiSelect/js/fselect.js"></s:url>"></script>
<script src="<s:url value="/assets/web/common/bootstrapvalidator/dist/js/bootstrapValidator.js"></s:url>"></script>
<%@ include file="/WEB-INF/views/include/footer.jsp" %>
<!-- dialog -->
<%@ include file="/WEB-INF/views/include/dialog.jsp" %>


<script type="text/javascript">
    //基本路径
    var baseUrl = "<s:url value="/qestionReport"></s:url>/"
    //jqgrid的表格高度
    var height = 320;
    //jqgrid表格行头的中文
    var colNames = ['', '协调状态', '项目名', '基本情况', '需协调事项', '附件', '责任单位', '企业联系人', '涉及部门', '承办单位', '分管县领导', '上报人', '上报时间'];
    var colModel = [
        {name: 'sysId', width: 60, hidden: true, key: true},
        {name: 'aaa001', index: 'aaa001', width: 100, editable: true, formatter: aa10Fmatter, cellattr: addCellAttr},
        {name: 'projectName', index: 'projectName', width: 180, editable: true},
        {name: 'baseInfo', index: 'baseInfo', width: 350, editable: true},
        {name: 'helpInfo', index: 'helpInfo', width: 350, editable: true},
        {
            name: 'taxproof',
            index: 'taxproof',
            width: 120,
            editable: true,
            formatter: showbtnFmatter,
            edittype: 'custom'
        },
        {name: 'resDept', index: 'resDept', width: 160, editable: true},
        {name: 'contact', index: 'contact', width: 120, editable: true},
        {name: 'involveUnit', index: 'involveUnit', width: 120, editable: true},
        {name: 'organizer', index: 'organizer', width: 120, editable: true},
        {name: 'fGcountyLeader', index: 'fGcountyLeader', width: 120, editable: true},
        {name: 'reportUser', index: 'reportUser', width: 120, editable: true},
        {name: 'reportTime', index: 'reportTime', width: 120, editable: true}
    ];

    //jqgrid的具体执行方法
    jqgrid({
        shrinkToFit: false,
        gridTableId: "#gridTable",
        gridPagerId: "#gridPager"
    });
    //开启冻结列
    $("#gridTable").jqGrid('setFrozenColumns');
    //加载查询对话框
    // $("#queryDialog").load(getUrl("filter"));
    //重置表单
    function reset() {
        resetForm("#formDialog form");
    }

    //不同用户显示不通按钮
    var userType = ${user.branchType};
    var userRole = "${user.role}";
    if (userRole == "责任人") {
        //显示（搜索、导出督查任务）
        $("#create").css("display", "inline");              //我要协调
        $("#edits").css("display", "inline");               //我要修改
    } else {
        if (userType == "4") {
            $("#create").css("display", "inline");              //我要协调
            $("#edits").css("display", "inline");               //我要修改
        }
        if (userType == "1") {
            $("#create").css("display", "inline");              //我要协调
            $("#edits").css("display", "inline");               //我要修改
        }
        if (userType == "0") {
            $("#create").css("display", "inline");              //我要协调
            $("#edits").css("display", "inline");               //我要修改
        }
        //管理员菜单
        if (userType == "2") {
            $("#create").css("display", "inline");              //我要协调
            $("#edits").css("display", "inline");               //我要修改
            $("#edits1").css("display", "inline");              //审核批转成攻坚任务
            $("#revoke").css("display", "inline");              //撤销协调
            $("#cancelProblem").css("display", "inline");       //一键处理完成
        }
    }

    var exportData = '';
    //显示查询对话框
    var queryDialog = $("#queryDialog");


    //最新搜索
    $("#query").click(function () {
        var url = '/qestionReport';
        var searchWord = $("#searchWord").val();
        //先清空条件,多次调用时查询条件会累加
        $('#gridTable').jqGrid('clearGridData');
        $("#gridTable").jqGrid('setGridParam', {
            url: url,
            datatype: 'json',
            postData: {'searchWord': searchWord}, //发送数据
            page: 1
        }).trigger("reloadGrid"); //重新载入
    });

    // 旧搜索功能
    // $("#query").click(function () {
    //     showDialog({
    //         dialogTitle: '条件搜索',
    //         dialogBody: queryDialog,
    //         dialogFoot: "<button type='button' class='btn btn-primary' onclick='query()'>查询</button>" +
    //             "<button type='button' class='btn btn-pink' onclick='reset()'>重置</button>" +
    //             "<button type='button' class='btn btn-default' data-dismiss='modal'>关闭</button>"
    //     });
    // });
    // //具体查询方法
    // function query() {
    //     exportData = $('#formDialog form').serialize();
    //     seachJqgird("#gridTable", "#formDialog form");
    //     $("#formDialog").modal('hide');
    // }

    //更新操作
    $("#edits").click(function () {
        debugger
        var rowId = $('#gridTable').jqGrid('getGridParam', "selrow");
        var rowData = $("#gridTable").jqGrid('getRowData', rowId);
        var state = rowData.aaa001;
        if (!(state == "正在处理")) {
            alert("该状态不能修改，只能修改正在处理的协调问题！");
            return false;
        }
        showEditView();
    });
    $("#edits1").click(function () {
        showEditView1();
    });

    //一键处理完成
    $("#cancelProblem").click(function () {
        cancelProblemView();
    });

    function cancelProblemView() {
        showDeleteDialog({
            url: getUrl("cancelProblem"),
            tableId: "#gridTable",
            confirmTitle: "确认对话框",
            confirmMessage: "是否确定一键处理完成该问题?",
            confirmOk: "确定",
            confirmCancel: "取消",
            successMessage: "注销成功",
            successTitle: "消息对话框",
            failMessage: "注销失败",
            failTitle: "消息对话框",
            errorTitle: "警告提示框",
            errorMessage: "您当前尚未选中一行，请选择后再试",
            errorOk: "确定"
        });
    }

    //撤销协调
    $("#revoke").click(function () {
        revokeView();
    });

    function revokeView() {
        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "撤销协调",
            dialogUrl: getUrl("revoke"),
            dialogFoot: '<button type="button" class="btn btn-primary" onclick="revokeProblem()" id="updatebtn" >确认撤销</button>' +
                '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
            errorTitle: "消息对话框",
            errorMutiSelectMessage: '您当前选中多行，请重新选择',
            errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
            errorOk: '确定'
        });
    }

    /**
     * 撤销协调
     */
    function revokeProblem() {
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("revoke"),
            tableId: "#gridTable",
            successMessage: "提交成功",
            successTitle: '提示',
            failTitle: '提示',
        });
        //倒计时
        var btn = document.getElementById("submit");
        btn.disabled = true;
        countdown(5);
    }


    //催办操作
    $("#createLog").click(function () {
        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "修改",
            dialogUrl: getUrl("edit"),
            dialogFoot: '<button type="button" class="btn btn-primary" onclick="edit()" id="updatebtn" >更新</button>' +
                '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
            errorTitle: "消息对话框",
            errorMutiSelectMessage: '您当前选中多行，请重新选择',
            errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
            errorOk: '确定'
        });
    });

    //执行更新操作
    function edit() {
        console.log("更新操作")
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("edit"),
            tableId: "#gridTable",
            successMessage: "操作成功",
            successTitle: '操作对话框',
            //failMessage: '更新失败',
            failTitle: '消息对话框'
        });
    }

    function edit1() {
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("edit1"),
            tableId: "#gridTable",
            successMessage: "操作成功,该协调申请已经转为攻坚督查任务，请往督查任务菜单查看",
            successTitle: '操作对话框',
            //failMessage: '更新失败',
            failTitle: '消息对话框'
        });
    }

    //显示编辑对话框
    function showEditView() {
        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "问题修改",
            dialogUrl: getUrl("edit"),
            dialogFoot: '<button type="button" class="btn btn-primary" onclick="edit()" id="updatebtn" >更新</button>' +
                '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
            errorTitle: "消息对话框",
            errorMutiSelectMessage: '您当前选中多行，请重新选择',
            errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
            errorOk: '确定'
        });
    }

    function showEditView1() {
        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "审核转批成攻坚任务",
            dialogUrl: getUrl("edit1"),
            dialogFoot: '<button type="button" class="btn btn-primary" onclick="edit1()" id="updatebtn" >生成任务</button>' +
                '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
            errorTitle: "消息对话框",
            errorMutiSelectMessage: '您当前选中多行，请重新选择',
            errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
            errorOk: '确定'
        });
    }


    //显示查看详情
    function showView() {

        var rowData = $('#gridTable').jqGrid('getGridParam', "selrow");
        loadDialog({
            dialogTitle: '查看详情',
            dialogUrl: baseUrl + "detail/" + rowData,
            dialogFoot: '<button type="button" class="btn btn-default" data-dismiss="modal" id="showDetail" >关闭</button>'
        });
    }

    $(function () {
        $(window).resize(function () {
            $("#analyDataTab").setGridWidth($(window).width() * 0.99);
            $("#charDataTab").setGridWidth(document.body.clientWidth * 0.99);
        });
    });

    $("#exportSummary").click(function () {
        // exportData=decodeURIComponent(exportData,true);//解码
        var url = "/export/ExportSummary" + '?' + exportData;
        console.log(exportData);
        window.open(url);

    });

    //删除
    $("#delete").click(function () {
        showDeleteView();
    });

    //显示删除对话框
    function showDeleteView() {
        showDeleteDialog({
            url: getUrl("delete"),
            tableId: "#gridTable",
            confirmTitle: "确认对话框",
            confirmMessage: "是否确定删除?",
            confirmOk: "确定",
            confirmCancel: "取消",
            successMessage: "删除成功",
            successTitle: "消息对话框",
            failMessage: "删除失败",
            failTitle: "消息对话框",
            errorTitle: "警告提示框",
            errorMessage: "您当前尚未选中一行，请选择后再试",
            errorOk: "确定"
        });
    }

    //显示创建对话框
    $("#create").click(function () {
        loadDialog({
            dialogTitle: '申请协调',
            dialogUrl: getUrl("create"),
            dialogFoot: '<button id="submit" type="button" class="btn btn-primary  submit" onclick="create()">提交审核</button>' +
                '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>'
        });
    });

    //分类编辑框


    //保存数据
    function create() {
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("create"),
            tableId: "#gridTable",
            successMessage: "保存成功",
            successTitle: '保存对话框',
            //failMessage: '保存失败',
            failTitle: '消息对话框'
        });
        //倒计时
        var btn = document.getElementById("submit");
        btn.disabled = true
        countdown(5);
    }

    $("#gridTable").dblclick(function (e) {
        showView();
    });


    //流程图表js
    $(function () {
        var userType = ${user.branchType};
        if (userType == "4") {
        }
        if (userType == "1" || userType == "0") {
            $("#edits1").css("display", "none");
            $("#cancelProblem").css("display", "none");
        }
        if (userType == "2") {
        }

    })

    function aa10Fmatter(cellvalue, options, rowObject) {
        if (cellvalue == "1") {
            return "正在处理";
        } else if (cellvalue == "3") {
            return "处理完毕";
        } else if (cellvalue == "2") {
            return "转为攻坚督查";
        } else if (cellvalue == "0") {
            return "撤销协调";
        }
    }

    function addCellAttr(rowId, val, rawObject, cm, rdata) {
        if (rawObject.aaa001 == "2") {
            return "style='color:red'";
        }
    }

    //添加下载按钮
    function showbtnFmatter(cellvalue, options, rowObject) {
        if (cellvalue == null || cellvalue == "") {
            return "无上传材料";
        } else {
            var imgeHtml = " <button class=\"col-sm-5 btn btn-large btn-primary\" style='width: 80px;border:0 !important;padding: 5px 8px !important;'  onclick=\"downDetail('" + cellvalue + "'); \">下载附件</button> ";
            return imgeHtml;
        }
    }

    //下载按钮
    function downDetail(id) {
        var url = "/communal/download/" + id;
        window.open(url);
    }


</script>

</body>
</html>